package com.robot.topology.graph.domain;

public class Edge  {
  private final String id; 
  private final Vertex source;
  private final Vertex destination;
  private Double weight; 
  
  public Edge(String id, Vertex source, Vertex destination, Double weight) {
    this.id = id;
    this.source = source;
    this.destination = destination;
    this.weight = weight;
  }
  
  public String getId() {
    return id;
  }
  public Vertex getDestination() {
    return destination;
  }

  public Vertex getSource() {
    return source;
  }
  
  public Double getWeight() {
    return weight;
  }
  
  public void setWeight(Double weight) {
	this.weight = weight;
}

@Override
  public String toString() {
    return source.toString() + destination.toString();
  }
  
//@Override
  public String toStringWeight() {
//	String formatedWeight=NumberTools.formatDouble(getWeight());
   // return source.toString() + destination.toString() + ":" + formatedWeight;
    return source.toString() + destination.toString() + ":" + weight;
  }

@Override
public int hashCode() {
	final int prime = 31;
	int result = 1;
	result = prime * result
			+ ((destination == null) ? 0 : destination.hashCode());
	result = prime * result + ((id == null) ? 0 : id.hashCode());
	result = prime * result + ((source == null) ? 0 : source.hashCode());
	return result;
}

@Override
public boolean equals(Object obj) {
	if (this == obj)
		return true;
	if (obj == null)
		return false;
	if (getClass() != obj.getClass())
		return false;
	Edge other = (Edge) obj;
	if (destination == null) {
		if (other.destination != null)
			return false;
	} else if (!destination.equals(other.destination))
		return false;
	if (id == null) {
		if (other.id != null)
			return false;
	} else if (!id.equals(other.id))
		return false;
	if (source == null) {
		if (other.source != null)
			return false;
	} else if (!source.equals(other.source))
		return false;
	return true;
} 
  
} 